/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mx.its.dsw2.veterinarySystem.dao;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import mx.its.dsw2.veterinarySystem.modelo.DuenoMascota;

/**
 *
 * @author 100101
 */
@Stateless
public class DuenoMascotaDao extends AbstractDao<DuenoMascota> implements DuenoMascotaDaoLocal {
    @PersistenceContext(unitName = "veterinarySystem-ejbPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public DuenoMascotaDao() {
        super(DuenoMascota.class);
    }

    @Override
    public boolean findDuplicity(DuenoMascota petOwner) {
        Query q=em.createNamedQuery("DuenoMascota.findDuplicity");
        q.setParameter("nombre", petOwner.getNombre());
        q.setParameter("apellidoPaterno", petOwner.getApellidoPaterno());
        q.setParameter("apellidoMaterno", petOwner.getApellidoMaterno());
        return !q.getResultList().isEmpty();
    }
    
    
    
}
